package cn.birdbaby.plugins.annotator.fieldannotator.schema;

import cn.birdbaby.plugins.selector.field.PsiFieldSelector;
import cn.birdbaby.plugins.constants.Constants;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;

/**
 * @author llorando 9/8/24 3:44 pm
 */
public class SchemaSelector extends PsiFieldSelector {
    @Override
    public boolean match(PsiElement psiElement) {
        PsiClass psiClass= PsiTreeUtil.findChildOfType(psiElement,PsiClass.class);
        String name= psiClass.getName();
        //fixme npe
        if(name.endsWith(Constants.RESPONSE_SUFFIX)||name.endsWith(Constants.REQUEST_SUFFIX)) return true;
        return false;
    }

    @Override
    public String getName() {
        return Constants.AnnotationName.SCHEMA;
    }
}
